﻿// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.InfoCardConstants
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 8E14765A-6610-409A-BA36-099A0642905D
// Assembly location: E:\git\ALLIDA\windll\infocard.exe

using Microsoft.InfoCards.Diagnostics;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IdentityModel.Claims;
using System.Xml;

namespace Microsoft.InfoCards
{
  internal static class InfoCardConstants
  {
    private static string[] s_SelfIssuedClaims = new string[14]
    {
      InfoCardConstants.GivenName,
      InfoCardConstants.Surname,
      InfoCardConstants.EmailAddress,
      InfoCardConstants.StreetAddress,
      InfoCardConstants.Locality,
      InfoCardConstants.StateOrProvince,
      InfoCardConstants.PostalCode,
      InfoCardConstants.Country,
      InfoCardConstants.HomePhone,
      InfoCardConstants.OtherPhone,
      InfoCardConstants.MobilePhone,
      InfoCardConstants.DateOfBirth,
      InfoCardConstants.Gender,
      InfoCardConstants.Webpage
    };
    private static Dictionary<string, string> s_claimDisplayTags = new Dictionary<string, string>();
    private static Dictionary<string, string> s_claimDescription = new Dictionary<string, string>();
    private static XmlDictionaryReaderQuotas s_defaultQuotas = new XmlDictionaryReaderQuotas();
    private static List<string> s_localTokenFactoryWhiteList = new List<string>();
    private static List<string> s_policyElementsToBeProcessed = new List<string>();
    private const int DEFAULT_MAX_MESSAGE_SIZE = 20971520;
    private const int DEFAULT_MAX_MEX_CHAIN = 100;
    private const string MAX_MESSAGE_KEY = "MaximumMessageSize";
    private const string MAX_MEX_CHAIN = "MaximumMexChain";
    private const string INFOCARD_REGISTRY_KEY = "software\\microsoft\\infocard";
    private static int s_maxMessageSize;
    private static int s_maxMexChainLength;

    public static int MaximumMessageSize
    {
      get
      {
        return InfoCardConstants.s_maxMessageSize;
      }
    }

    public static int MaximumMexChainLength
    {
      get
      {
        return InfoCardConstants.s_maxMexChainLength;
      }
    }

    public static string RegistryKey
    {
      get
      {
        return "software\\microsoft\\infocard";
      }
    }

    public static string GivenName
    {
      get
      {
        return ClaimTypes.GivenName;
      }
    }

    public static string EmailAddress
    {
      get
      {
        return ClaimTypes.Email;
      }
    }

    public static string Surname
    {
      get
      {
        return ClaimTypes.Surname;
      }
    }

    public static string StreetAddress
    {
      get
      {
        return ClaimTypes.StreetAddress;
      }
    }

    public static string Locality
    {
      get
      {
        return ClaimTypes.Locality;
      }
    }

    public static string StateOrProvince
    {
      get
      {
        return ClaimTypes.StateOrProvince;
      }
    }

    public static string PostalCode
    {
      get
      {
        return ClaimTypes.PostalCode;
      }
    }

    public static string Country
    {
      get
      {
        return ClaimTypes.Country;
      }
    }

    public static string HomePhone
    {
      get
      {
        return ClaimTypes.HomePhone;
      }
    }

    public static string OtherPhone
    {
      get
      {
        return ClaimTypes.OtherPhone;
      }
    }

    public static string MobilePhone
    {
      get
      {
        return ClaimTypes.MobilePhone;
      }
    }

    public static string DateOfBirth
    {
      get
      {
        return ClaimTypes.DateOfBirth;
      }
    }

    public static string Gender
    {
      get
      {
        return ClaimTypes.Gender;
      }
    }

    public static string PPID
    {
      get
      {
        return ClaimTypes.PPID;
      }
    }

    public static string Webpage
    {
      get
      {
        return ClaimTypes.Webpage;
      }
    }

    public static bool DoesLocalTokenFactoryWhiteListContain(string nameSpaceValue, string value)
    {
      return InfoCardConstants.s_localTokenFactoryWhiteList.Contains(nameSpaceValue + "/" + value);
    }

    public static bool DoesPolicyElementsToBeProcessedListContain(
      string nameSpaceValue,
      string value)
    {
      return InfoCardConstants.s_policyElementsToBeProcessed.Contains(nameSpaceValue + "/" + value);
    }

    public static XmlDictionaryReaderQuotas DefaultQuotas
    {
      get
      {
        return InfoCardConstants.s_defaultQuotas;
      }
    }

    public static string[] SelfIssuedClaimsUris
    {
      get
      {
        return InfoCardConstants.s_SelfIssuedClaims;
      }
    }

    public static string PPIDClaimsUri
    {
      get
      {
        return InfoCardConstants.PPID;
      }
    }

    public static string ClaimDisplayTag(string key)
    {
      if (InfoCardConstants.s_claimDisplayTags.ContainsKey(key))
        return SR.GetString(InfoCardConstants.s_claimDisplayTags[key]);
      throw InfoCardTrace.ThrowHelperWarning((Exception) new ArgumentOutOfRangeException(SR.GetString("InvalidSelfIssuedUri")));
    }

    public static string ClaimsDescription(string key)
    {
      if (InfoCardConstants.s_claimDescription.ContainsKey(key))
        return SR.GetString(InfoCardConstants.s_claimDescription[key]);
      throw InfoCardTrace.ThrowHelperWarning((Exception) new ArgumentOutOfRangeException(SR.GetString("InvalidSelfIssuedUri")));
    }

    static InfoCardConstants()
    {
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.GivenName, "GivenNameText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.EmailAddress, "EmailAddressText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.Country, "CountryText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.DateOfBirth, "DateOfBirthText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.Gender, "GenderText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.HomePhone, "HomePhoneText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.Locality, "LocalityText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.MobilePhone, "MobilePhoneText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.OtherPhone, "OtherPhoneText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.PostalCode, "PostalCodeText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.StateOrProvince, "StateOrProvinceText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.StreetAddress, "StreetAddressText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.Surname, "SurnameText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.PPID, "PPIDText");
      InfoCardConstants.s_claimDisplayTags.Add(InfoCardConstants.Webpage, "WebPageText");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.GivenName, "GivenNameDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.EmailAddress, "EmailAddressDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.Country, "CountryDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.DateOfBirth, "DateOfBirthDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.Gender, "GenderDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.HomePhone, "HomePhoneDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.Locality, "LocalityDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.MobilePhone, "MobilePhoneDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.OtherPhone, "OtherPhoneDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.PostalCode, "PostalCodeDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.StateOrProvince, "StateOrProvinceDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.StreetAddress, "StreetAddressDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.Surname, "SurnameDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.PPID, "PPIDDescription");
      InfoCardConstants.s_claimDescription.Add(InfoCardConstants.Webpage, "WebPageDescription");
      InfoCardConstants.s_defaultQuotas.MaxDepth = 32;
      InfoCardConstants.s_defaultQuotas.MaxStringContentLength = 8192;
      InfoCardConstants.s_defaultQuotas.MaxArrayLength = 20971520;
      InfoCardConstants.s_defaultQuotas.MaxBytesPerRead = 4096;
      InfoCardConstants.s_defaultQuotas.MaxNameTableCharCount = 16384;
      InfoCardConstants.s_maxMessageSize = 20971520;
      InfoCardConstants.s_maxMexChainLength = 100;
      using (new SystemIdentity(false))
      {
        using (Microsoft.Win32.RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("software\\microsoft\\infocard", false))
        {
          if (registryKey != null)
          {
            object obj1 = registryKey.GetValue(nameof (MaximumMessageSize), (object) 20971520);
            if (obj1 is int && (int) obj1 > 0 && (int) obj1 * 1024 > 0)
              InfoCardConstants.s_maxMessageSize = (int) obj1 * 1024;
            object obj2 = registryKey.GetValue("MaximumMexChain", (object) 100);
            if (obj2 is int)
            {
              if ((int) obj2 > 0)
                InfoCardConstants.s_maxMexChainLength = (int) obj2;
            }
          }
        }
      }
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://schemas.xmlsoap.org/ws/2005/02/trust/SignatureAlgorithm");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://schemas.xmlsoap.org/ws/2005/02/trust/EncryptionAlgorithm");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://schemas.xmlsoap.org/ws/2005/02/trust/CanonicalizationAlgorithm");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://schemas.xmlsoap.org/ws/2005/02/trust/SignWith");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://schemas.xmlsoap.org/ws/2005/02/trust/Claims");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://schemas.xmlsoap.org/ws/2005/02/trust/TokenType");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://schemas.xmlsoap.org/ws/2005/02/trust/KeyType");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://schemas.xmlsoap.org/ws/2005/02/trust/KeySize");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://schemas.xmlsoap.org/ws/2005/02/trust/EncryptWith");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://schemas.xmlsoap.org/ws/2005/02/trust/RequestType");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/SignatureAlgorithm");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/EncryptionAlgorithm");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/CanonicalizationAlgorithm");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/SignWith");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Claims");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/TokenType");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/KeyType");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/KeySize");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/EncryptWith");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/RequestType");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/SecondaryParameters");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/KeyWrapAlgorithm");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/RequestSecurityTokenTemplate");
      InfoCardConstants.s_localTokenFactoryWhiteList.Add("http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512/RequestSecurityTokenTemplate");
      InfoCardConstants.s_policyElementsToBeProcessed.AddRange((IEnumerable<string>) InfoCardConstants.s_localTokenFactoryWhiteList);
      InfoCardConstants.s_policyElementsToBeProcessed.Add("http://schemas.xmlsoap.org/ws/2004/09/policy/AppliesTo");
      InfoCardConstants.s_policyElementsToBeProcessed.Add("http://www.w3.org/ns/ws-policy/AppliesTo");
    }
  }
}
